package cn.wygandwdn.core.registry.nacos;

import cn.wygandwdn.core.registry.ServiceRegistry;
import com.alibaba.nacos.api.exception.NacosException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * @description:
 * @author: WYG
 * @time: 2021/10/27 16:53
 */

public class NacosRegistry implements ServiceRegistry {

    private static final Logger log = LoggerFactory.getLogger(NacosRegistry.class);

    @Override
    public void registry(String serviceName, String host, int port) {
        try {
            NacosUtil.registerService(serviceName, host, port);
        } catch (NacosException e) {
            log.error("服务 [{}] 注册失败: {}", serviceName, e);
        }
    }

    @Override
    public void clearRegistry(String host, int port) {
        NacosUtil.clearRegistry(host, port);
    }
}
